import { listGoodsBatch } from "@/api/base/goodsBatch"

export function toOptions(data) {
  data.forEach((item) => {
    item.codeName = item.customerCode + '  ' + item.customerName
  })
  return data
}
// 批号处理
export function batchNumber(data) {
  return (
    data.substring(0, data.indexOf('，')) ||
    data.substring(0, data.indexOf(','))
  )
}

// 客户编号处理
export function dispose(data) {
  const index = escape(data).indexOf('%u')
  const re = /^[0-9a-zA-Z]*$/g
  if (index > 0) {
    let age = data.substring(0, index - 2)
    age = age.trim()
    if (!re.test(age.charAt(age.length - 1))) {
      age = age.substring(0, age.length - 1)
      return age
    }
  } else {
    return data
  }
}
// 价格处理
export function number(data) {
  return data.toFixed(0)
}

// 浓度处理
export function toConcentration(data) {
  let concentration = ''
  if (data.lastIndexOf('-') !== -1) {
    concentration = data.slice(data.lastIndexOf('-') + 1)
    data.slice(data.lastIndexOf('-') + 1)
  } else {
    console.log(data, '46464646');
    concentration = data.slice(data.lastIndexOf('，') + 1)
  }
  return concentration
  // return data.toFixed(0)
}
